package Checkers;

//this is the polynomial used for the evaluation function.
//even indices = weights (importance of values)
//odd indices = values (environmental factors)

public class Poly
{
    int[] poly;
    
    public Poly(int numTerms)
    {
        poly=new int[numTerms*2];
    }
        
    public int size()
    {
        return poly.length/2;
    }

    public void setWeight(int index, int weight)
    {
        poly[index]=weight;
    }

    public void setVal(int index, int value)
    {
        poly[index+1]=value;
    }
    
    public int getWeight(int index)
    {
        return poly[index];
    }

    public int getVal(int index)
    {
        return poly[index+1];
    }

    public int eval() //assumes all values are filled in
    {
        int x=0;
        for(int i=0;i<poly.length;i+=2)
        {
            x+=poly[i]*poly[i+1];
        }
        return x;
    }
}
